<?php
/***
 * 描述：手机前台首页面
 * @category		Mobile		
 * @package			Action			
 * @subpackage		
 * @author			wanght <whtaok@gmail.com>
 * @since			2013-4-6
 * @version			$Id: IndexAction.class.php 51 2013-11-18 07:31:29Z whtaok@gmail.com $
 */
class IndexAction extends MobileAction {
	
	/**
	 * 描述：初始化模块,不继承Mobile的初始化方法
	 * @access		protected
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-4-14
	 */
	protected  function _initialize() {
		
	}
	/**
	 * 描述：手机前台首页面
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function indexAct() {
		//检查是否已经选择了区域
		$this->checkShop();
		
		//热门商品
		$this->_showHotProdList();
		$this->_showTgProdList();
		$this->display('index');
	}
	
	/**
	 * 描述：显示配送区域列表
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function showChgshopAct(){
		$mod = new ShopLibModel();
		$shopList = $mod->field('id,name,address,district,deliver_around,link_way')->findOpenedList();
		$this->assign('shopList',$shopList);
		$this->display('shop');
	}

	/**
	 * 描述：切换配送区域
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function doChgshopAct(){
		$mod = new ShopLibModel();
		$list = $mod->field('id,address,district')->findOpenedList(I('shop_id'));
		if(count($list)==1){
			$rtnData = array(
					'error'=>0,
					'message'=>'选择成功',
			);
			cookie(COK_SHOP,$list[0]['id'].'|'.$list[0]['district'].'|'.$list[0]['address']);
			session(SES_SHOP_ID,$list[0]['id']);
		}else{
			$rtnData = array(
					'error'=>1,
					'message'=>'该区域尚未开始营业，请稍后',
			);
		}
		$this->ajaxReturn($rtnData);
	}
	/**
	 * 描述：关于我们列表页
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function showAboutListAct(){
		$this->display('about_list');
	}
	/**
	 * 描述：关于我们
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function showAboutAct(){
		$mod = new ShopSettingModel();
		$detail = $mod->findAboutDetail(I('id'));
		$this->assign('detail',$detail);
		$this->display('about');
	}
	
	////////////////////////////////////////////////////////////////////////////////////////	
	private function _showHotProdList(){
		$savePath = C('REALPATH_SHOP').'/'.$this->curr_shop_id.'/hot';
		
		$hotProdList = F_CACHE($savePath);
		if(is_array($hotProdList)){
			$hotProd['list'] = array_slice($hotProdList, 0, 3);
			$hotProd['col'] = 12/count($hotProd['list']);
			$this->assign('hotProd',$hotProd);
		}
	}

}

?>